﻿using System;
using SharpSqlAnalyzer.nodes;

namespace SharpSqlAnalyzer.stmt.db2
{
	// Token: 0x020001D4 RID: 468
	public class TDb2CreateTrigger : TStoredProcedureSqlStatement
	{
		// Token: 0x06000FB5 RID: 4021 RVA: 0x0030C0B3 File Offset: 0x0030A2B3
		public TDb2CreateTrigger(EDbVendor dbvendor) : base(dbvendor)
		{
			this.sqlstatementtype = ESqlStatementType.sstdb2createtrigger;
		}

		// Token: 0x06000FB6 RID: 4022 RVA: 0x0030C0C7 File Offset: 0x0030A2C7
		internal override void buildsql()
		{
		}

		// Token: 0x06000FB7 RID: 4023 RVA: 0x0030C0C9 File Offset: 0x0030A2C9
		internal override void clear()
		{
		}

		// Token: 0x06000FB8 RID: 4024 RVA: 0x0030C0CB File Offset: 0x0030A2CB
		internal override string getasprettytext()
		{
			return "";
		}

		// Token: 0x06000FB9 RID: 4025 RVA: 0x0030C0D2 File Offset: 0x0030A2D2
		internal virtual void iterate(TVisitorAbs pvisitor)
		{
		}

		// Token: 0x170002EE RID: 750
		// (get) Token: 0x06000FBA RID: 4026 RVA: 0x0030C0D4 File Offset: 0x0030A2D4
		public override TObjectName StoredProcedureName
		{
			get
			{
				return this.triggerName;
			}
		}

		// Token: 0x170002EF RID: 751
		// (get) Token: 0x06000FBB RID: 4027 RVA: 0x0030C0DC File Offset: 0x0030A2DC
		// (set) Token: 0x06000FBC RID: 4028 RVA: 0x0030C0E4 File Offset: 0x0030A2E4
		public virtual TObjectName TriggerName
		{
			get
			{
				return this.triggerName;
			}
			set
			{
				this.triggerName = value;
			}
		}

		// Token: 0x170002F0 RID: 752
		// (get) Token: 0x06000FBD RID: 4029 RVA: 0x0030C0ED File Offset: 0x0030A2ED
		// (set) Token: 0x06000FBE RID: 4030 RVA: 0x0030C0F5 File Offset: 0x0030A2F5
		public virtual TTable OnTable
		{
			get
			{
				return this.onTable;
			}
			set
			{
				this.onTable = value;
			}
		}

		// Token: 0x06000FBF RID: 4031 RVA: 0x0030C100 File Offset: 0x0030A300
		public override int doParseStatement(TCustomSqlStatement psql)
		{
			if (this.rootNode == null)
			{
				return -1;
			}
			TCreateTriggerSqlNode tcreateTriggerSqlNode = (TCreateTriggerSqlNode)this.rootNode;
			base.doParseStatement(psql);
			this.triggerName = tcreateTriggerSqlNode.TriggerName;
			this.onTable = tcreateTriggerSqlNode.OnTable;
			this.tables.addTable(this.onTable);
			base.DatabaseObjects.Add(this.triggerName);
			TTriggerAction triggerAction = tcreateTriggerSqlNode.TriggerAction;
			this.whenExpr = triggerAction.WhenExpr;
			if (triggerAction.StmtNode != null)
			{
				triggerAction.StmtNode.doParse(this, ESqlClause.unknown);
				this.BodyStatements.add(triggerAction.StmtNode.Stmt);
			}
			else if (triggerAction.CompoundSqlNode != null)
			{
				TCompoundSqlNode compoundSqlNode = triggerAction.CompoundSqlNode;
				if (compoundSqlNode.DeclareStmts != null)
				{
					compoundSqlNode.DeclareStmts.doParse(this, ESqlClause.unknown);
					for (int i = 0; i < compoundSqlNode.DeclareStmts.size(); i++)
					{
						this.TopStatement.SymbolTable.Push(new TSymbolTableItem(10, this, compoundSqlNode.DeclareStmts.getStatementSqlNode(i).Stmt));
						this.DeclareStatements.add(compoundSqlNode.DeclareStmts.getStatementSqlNode(i).Stmt);
					}
				}
				if (compoundSqlNode.Stmts != null)
				{
					compoundSqlNode.Stmts.doParse(this, ESqlClause.unknown);
					for (int j = 0; j < compoundSqlNode.Stmts.size(); j++)
					{
						this.BodyStatements.add(compoundSqlNode.Stmts.getStatementSqlNode(j).Stmt);
					}
				}
				if (compoundSqlNode.DeclareStmts != null)
				{
					for (int k = 0; k < compoundSqlNode.DeclareStmts.size(); k++)
					{
						this.TopStatement.SymbolTable.Pop();
					}
				}
			}
			return 0;
		}

		// Token: 0x170002F1 RID: 753
		// (get) Token: 0x06000FC0 RID: 4032 RVA: 0x0030C2AA File Offset: 0x0030A4AA
		// (set) Token: 0x06000FC1 RID: 4033 RVA: 0x0030C2B2 File Offset: 0x0030A4B2
		public virtual TExpression WhenExpr
		{
			get
			{
				return this.whenExpr;
			}
			set
			{
				this.whenExpr = value;
			}
		}

		// Token: 0x06000FC2 RID: 4034 RVA: 0x0030C2BC File Offset: 0x0030A4BC
		public override void accept(TParseTreeVisitor v)
		{
			v.preVisit(this);
			if (this.whenExpr != null)
			{
				this.whenExpr.accept(v);
			}
			if (this.DeclareStatements.size() > 0)
			{
				this.DeclareStatements.accept(v);
			}
			if (this.BodyStatements.size() > 0)
			{
				this.BodyStatements.accept(v);
			}
			v.postVisit(this);
		}

		// Token: 0x0400137E RID: 4990
		private TObjectName triggerName;

		// Token: 0x0400137F RID: 4991
		private TTable onTable;

		// Token: 0x04001380 RID: 4992
		private TExpression whenExpr;
	}
}
